<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <title>
            jQuery Calx 2.2.7 Sample
        </title>
        <link href="css/bootstrap.css" rel="stylesheet" type="text/css">
        <link href="css/sb-admin.css" rel="stylesheet" type="text/css">
        <link href="css/style.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css" type="text/css">

        <style>
            .chead{
                background:#ccf;
                text-align: center;
                vertical-align: middle;
            }

            .rhead{
                background: #cfc;
                padding: 0 5px;
                text-align: right;
                vertical-align: middle;
            }

            span.formula{
                font-size: 11px;
            }
        </style>
    </head>
    <body>
        <div id="wrapper">
            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                        <span class="sr-only">Toggle navigation</span>
                    </button>
                    <a class="navbar-brand" href="#">jQuery Calx 2.2.7 Sample</a>
                </div>
                <div class="collapse navbar-collapse navbar-ex1-collapse">
                    <ul class="nav navbar-nav side-nav">
                        <li class="active"><a href="#">Index</a></li>
                        <li><a href="basic.html">Basic Calculation</a></li>
                        <li><a href="dynamic_form.html">Dynamic Form</a></li>
                        <li><a href="checkbox.html">Cehckbox, Radio, and Select</a></li>
                        <li><a href="chart.html">Drawing Chart</a></li>
                        <li><a href="multisheet.html">Multiple Sheet</a></li>
                        <li><a href="formula.html">Formula Showcase</a></li>
                        <li><a href="server_side.html">Server Side Formula</a></li>
                        <li class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                Sample Application
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="app/budget_planner.html">Budget Planner</a></li>
                                <li><a href="app/amortization_schedule.html">Amortization Schedule</a></li>
                                <li><a href="app/home_mortgage.html">Home Mortgage Calc</a></li>
                                <li><a href="app/home_expense.html">Home Expense Calc</a></li>
                            </ul>
                        </li>

                    </ul>
                </div>
            </nav>
            <div id="page-wrapper">
                <form action="" class="form-horizontal" id="sheet1">
                    <div class="row">
                        <div class="col-lg-10">
                            <h2>Multi Sheet</h2>
                        </div>
                        <div class="col-lg-2">
                            <button class="btn btn-primary pull-right" id="show_formula" data-shown="0">Show Formula</button>
                        </div>
                    </div>
                    <hr>
                    <div class="form-group">
                        <label class="col-md-12">Sheet 1</label class="col-md-12">
                    </div>
                    <table class="table" style="width:100%">
                        <thead>
                            <tr>
                                <td class="chead">&nbsp;</td>
                                <td class="chead">A</td>
                                <td class="chead">B</td>
                                <td class="chead">C</td>
                                <td class="chead">D</td>
                                <td class="chead">E</td>
                                <td class="chead">F</td>
                                <td class="chead">G</td>
                                <td class="chead">H</td>
                                <td class="chead">I</td>
                                <td class="chead">J</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="rhead">1</td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0,0[.]00" data-cell="A1" value="100"></td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0,0[.]00" data-cell="B1" value="150"></td>
                                <td><input class="form-control input-sm" data-formula="A1+B1" data-format="0,0[.]00" data-cell="C1"></td>
                                <td><input class="form-control input-sm" data-formula="C1*2" data-format="0,0[.]00" data-cell="D1"></td>
                                <td><input class="form-control input-sm" data-formula="C1*3" data-format="0,0[.]00" data-cell="E1"></td>
                                <td><input class="form-control input-sm" data-formula="C1*4" data-format="0,0[.]00" data-cell="F1"></td>
                                <td><input class="form-control input-sm" data-formula="D1+E1+F1" data-format="0,0[.]00" data-cell="G1"></td>
                                <td><input class="form-control input-sm" data-formula="CONCAT('G1 is: ', G1)" data-format="0,0[.]00" data-cell="H1"></td>
                                <td><input class="form-control input-sm" data-formula="G1+100" data-format="0,0[.]00" data-cell="I1"></td>
                                <td><input class="form-control input-sm" data-formula="D1+I1" data-format="0,0[.]00" data-cell="J1"></td>
                            </tr>
                        </tbody>
                    </table>
                </form>

                <form action="" class="form-horizontal" id="sheet2">
                    <div class="form-group">
                        <label class="col-md-12">Sheet 2</label class="col-md-12">
                    </div>
                    <table class="table" style="width:100%">
                        <thead>
                            <tr>
                                <td class="chead">&nbsp;</td>
                                <td class="chead">A</td>
                                <td class="chead">B</td>
                                <td class="chead">C</td>
                                <td class="chead">D</td>
                                <td class="chead">E</td>
                                <td class="chead">F</td>
                                <td class="chead">G</td>
                                <td class="chead">H</td>
                                <td class="chead">I</td>
                                <td class="chead">J</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="rhead">1</td>
                                <td><input class="form-control input-sm" data-formula="#sheet1!A1" data-format="0,0[.]00" data-cell="A1"></td>
                                <td><input class="form-control input-sm" data-formula="#sheet1!B1" data-format="0,0[.]00" data-cell="B1"></td>
                                <td><input class="form-control input-sm" data-formula="#sheet3!C1" data-format="0,0[.]00" data-cell="C1"></td>
                                <td><input class="form-control input-sm" data-formula="#sheet3!D1" data-format="0,0[.]00" data-cell="D1"></td>
                                <td><input class="form-control input-sm" data-formula="C1*3" data-format="0,0[.]00" data-cell="E1"></td>
                                <td><input class="form-control input-sm" data-formula="D1*4" data-format="0,0[.]00" data-cell="F1"></td>
                                <td><input class="form-control input-sm" data-formula="SUM(A1:D1)" data-format="0,0[.]00" data-cell="G1"></td>
                                <td><input class="form-control input-sm" data-formula="CONCAT('G1 is: ', G1)" data-format="0,0[.]00" data-cell="H1"></td>
                                <td><input class="form-control input-sm" data-formula="G1+100" data-format="0,0[.]00" data-cell="I1"></td>
                                <td><input class="form-control input-sm" data-formula="D1+I1" data-format="0,0[.]00" data-cell="J1"></td>
                            </tr>
                        </tbody>
                    </table>
                </form>

                <form action="" class="form-horizontal" id="sheet3">
                    <div class="form-group">
                        <label class="col-md-12">Sheet 3</label class="col-md-12">
                    </div>
                    <table class="table" style="width:100%">
                        <thead>
                            <tr>
                                <td class="chead">&nbsp;</td>
                                <td class="chead">A</td>
                                <td class="chead">B</td>
                                <td class="chead">C</td>
                                <td class="chead">D</td>
                                <td class="chead">E</td>
                                <td class="chead">F</td>
                                <td class="chead">G</td>
                                <td class="chead">H</td>
                                <td class="chead">I</td>
                                <td class="chead">J</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="rhead">1</td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0[.]00 %" data-cell="A1" value="50%"></td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0,0[.]00" data-cell="B1"></td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0,0[.]00" data-cell="C1" value="200"></td>
                                <td><input class="form-control input-sm" data-formula="" data-format="0,0[.]00" data-cell="D1" value="400"></td>
                                <td><input class="form-control input-sm" data-formula="#sheet2!E1+C1" data-format="0,0[.]00" data-cell="E1"></td>
                                <td><input class="form-control input-sm" data-formula="#sheet2!B1" data-format="0,0[.]00" data-cell="F1"></td>
                                <td><input class="form-control input-sm" data-formula="D1+E1+F1" data-format="0,0[.]00" data-cell="G1"></td>
                                <td><input class="form-control input-sm" data-formula="CONCAT('G1 is: ', G1)" data-format="0,0[.]00" data-cell="H1"></td>
                                <td><input class="form-control input-sm" data-formula="G1*A1" data-format="0,0[.]00" data-cell="I1"></td>
                                <td><input class="form-control input-sm" data-formula="D1+I1" data-format="0,0[.]00" data-cell="J1"></td>
                            </tr>
                        </tbody>
                        </tr>
                    </table>

                </form>
            </div>
        </div>

        <script src="js/jquery-calx-sample-2.2.7.min.js" type="text/javascript"></script>
        <script src="js/bootstrap.js" type="text/javascript"></script>
        <script>

            $('#sheet1, #sheet2, #sheet3').calx();

            $('#show_formula').click(function(e){
                e.preventDefault();

                if($(this).attr('data-shown') == '0'){
                    $('[data-formula],[data-cell]').each(function(){
                        $(this).after('<span class="formula">'+$(this).attr('data-cell')+($(this).attr('data-formula') ? ' = '+$(this).attr('data-formula') : '')+'&nbsp;</span>');
                    });

                    $(this).attr('data-shown', 1).html('Hide Formula');
                }else{
                    $('span.formula').remove();
                    $(this).attr('data-shown', 0).html('Show Formula');
                }
            });
        </script>
    </body>
</html>